<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
    <h4 class="modal-title" id="myModalLabel">管理员添加</h4>
</div>
<form class="form-horizontal J_ajaxForm" role="form" method="post" action="" data-validate="validate">
    <div class="modal-body">

        <div class="form-group">
            <label class="col-sm-3 control-label">管理员账号</label>
            <div class="col-sm-9">
                <input type="text" class="form-control" placeholder="管理员账号" name="username">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">管理员名称</label>
            <div class="col-sm-9">
                <input type="text" class="form-control" placeholder="管理员名称" name="name">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">手机号</label>
            <div class="col-sm-9">
                <input type="text" class="form-control" placeholder="手机号" name="phone">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">密码</label>
            <div class="col-sm-9">
                <input type="password" class="form-control" placeholder="密码" name="password">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">确认密码</label>
            <div class="col-sm-9">
                <input type="password" class="form-control" placeholder="密码" name="repassword">
            </div>
        </div>

    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary J_ajaxSubmitBtn">提交</button>
    </div>
</form>

<script>

    $(document).ready(function () {

        $("form").attr("action", common_conf.requestUrl+'managerUser/add');
    });

    function validate($from) {
        var username = $from.find('input[name="username"]');
        if ($.trim(username.val()) == '') {
            return '账号不能为空';
        }
        var name = $from.find('input[name="name"]');
        if ($.trim(name.val()) == '') {
            return '  名称不能为空';
        }
        var phone = $from.find('input[name="phone"]');
        if ($.trim(phone.val()) == '') {
            return '手机不能为空';
        }

        if(!isPhoneNo(phone.val())){
            return '非法的手机号';
        }
        var password = $from.find('input[name="password"]');
        if ($.trim(password.val()) == '') {
            return '密码不能为空';
        }

        if ($.trim(password.val()).length<6) {
            return '密码不能小于6位';
        }

        var repassword = $from.find('input[name="repassword"]');
        if ($.trim(repassword.val()) == '') {
            return '重复密码不能为空';
        }

        if(password.val()!=repassword.val()){
            return '两次密码不相同';
        }

        return true;
    }
</script>